package com.china08.yxyapi.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * API响应
 * 
 * @author Ertao.Fang
 *
 * @param <T>
 */
@ApiModel("Response")
@JsonIgnoreProperties
public class ResModel {

    /** 成功 */
    public static final String EVENT_SUCCESS = "0";
    /** 失败 */
    public static final String EVENT_ERROR = "1";

    /** 状态:0-正常 */
    @ApiModelProperty(value = "0:正常,1:异常;", allowableValues = "0,1", required = true)
    private String event = "0";

    /** 返回信息 */
    @ApiModelProperty(value = "返回的信息", required = true)
    private String msg = "success";

    /**
     * 成功
     * 
     * @param msg
     * @return
     */
    public ResModel success(String msg) {
        this.msg = msg;
        this.event = EVENT_SUCCESS;
        return this;
    }

    /**
     * 失败
     * 
     * @param msg
     * @return
     */
    public ResModel error(String msg) {
        this.msg = msg;
        this.event = EVENT_ERROR;
        return this;
    }

    // getters and setters
    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public String getMsg() {
        return msg;
    }

}
